<?php /* SVN: $Id: admin_edit.ctp 2895 2010-09-02 10:58:05Z sakthivel_135at10 $ */ ?>
<div class="paymentGateways form">
	<?php echo $this->Form->create('PaymentGateway', array('class' => 'normal'));?>
		<fieldset>
			<?php
				echo $this->Form->input('id');
				echo $this->Form->input('name');
				echo $this->Form->input('description');
				if ($this->request->data['PaymentGateway']['id'] != ConstPaymentGateways::Wallet):
					echo $this->Form->input('is_test_mode', array('label' => __l('Test Mode?')));
				endif;
				if ($this->request->data['PaymentGateway']['id'] == ConstPaymentGateways::PayPal) {
					echo $this->Form->input('is_mass_pay_enabled', array('label' => __l('Mass Pay Enabled?')));
				}
				foreach($paymentGatewaySettings as $paymentGatewaySetting) {
					$options['type'] = $paymentGatewaySetting['PaymentGatewaySetting']['type'];
					if($paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'is_enable_for_project'):
						$options['label'] = __l('Enable for project listing');
					elseif($paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'is_enable_for_pledge'):
						$options['label'] = __l('Enable for pledge');
					elseif($paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'is_enable_for_add_to_wallet'):
						$options['label'] = __l('Enable for add to wallet');
					endif;
					$options['value'] = $paymentGatewaySetting['PaymentGatewaySetting']['test_mode_value'];
					$options['div'] = array('id' => "setting-{$paymentGatewaySetting['PaymentGatewaySetting']['key']}");
					if($options['type'] == 'checkbox' && !empty($options['value'])):
						$options['checked'] = 'checked';
					else:
						$options['checked'] = '';
					endif;
					if($options['type'] == 'select'):
						$selectOptions = explode(',', $paymentGatewaySetting['PaymentGatewaySetting']['options']);
						$paymentGatewaySetting['PaymentGatewaySetting']['options'] = array();
						if(!empty($selectOptions)):
							foreach($selectOptions as $key => $value):
								if(!empty($value)):
									$paymentGatewaySetting['PaymentGatewaySetting']['options'][trim($value)] = trim($value);
								endif;
							endforeach;
						endif;
						$options['options'] = $paymentGatewaySetting['PaymentGatewaySetting']['options'];
					endif;
					if (!empty($paymentGatewaySetting['PaymentGatewaySetting']['description']) && empty($options['after'])):
						$options['help'] = "{$paymentGatewaySetting['PaymentGatewaySetting']['description']}";
					else:
						$options['help'] = '';
					endif;
					if ($paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'is_enable_for_project' || $paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'is_enable_for_pledge' || $paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'is_enable_for_add_to_wallet'):
						echo $this->Form->input("PaymentGatewaySetting.{$paymentGatewaySetting['PaymentGatewaySetting']['id']}.test_mode_value", $options);
					endif;
				}
				if ($paymentGatewaySettings && $this->request->data['PaymentGateway']['id'] != ConstPaymentGateways::Wallet) {
			?>

			<?php
				$j = $i = $z = $n = 0;
				foreach($paymentGatewaySettings as $paymentGatewaySetting) {
					$options['type'] = $paymentGatewaySetting['PaymentGatewaySetting']['type'];
					$options['value'] = $paymentGatewaySetting['PaymentGatewaySetting']['test_mode_value'];
					$options['div'] = array('id' => "setting-{$paymentGatewaySetting['PaymentGatewaySetting']['key']}");
					if($options['type'] == 'checkbox' && $options['value']):
						$options['checked'] = 'checked';
					endif;
					if($options['type'] == 'select'):
                        $selectOptions = explode(',', $paymentGatewaySetting['PaymentGatewaySetting']['options']);
                        $paymentGatewaySetting['PaymentGatewaySetting']['options'] = array();
                        if(!empty($selectOptions)):
                            foreach($selectOptions as $key => $value):
                                if(!empty($value)):
                                    $paymentGatewaySetting['PaymentGatewaySetting']['options'][trim($value)] = trim($value);
                                endif;
                            endforeach;
                        endif;
                        $options['options'] = $paymentGatewaySetting['PaymentGatewaySetting']['options'];
                    endif;
					$options['label'] = false;
					if (!empty($paymentGatewaySetting['PaymentGatewaySetting']['description']) && empty($options['after'])):
						$options['help'] = "{$paymentGatewaySetting['PaymentGatewaySetting']['description']}";
					else:
						$options['help'] = '';
					endif;
			?>
					<?php if($paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'payee_account'): ?>
						<fieldset class="fields-block round-5">
							<h3><?php echo __l('Payee Details'); ?></h3>
							<div class="clearfix test-mode-content">
							<div class="clearfix">
								<div class="test-mode-left test-mode-label grid_6 prefix_5">
									<label for="PaymentGatewaySetting1TestModeValue"><?php echo __l('Test Mode'); ?></label>
								</div>
								<div class="test-mode-right test-mode-label grid_5 prefix_3">
									<label for="PaymentGatewaySetting1LiveModeValue"><?php echo __l('Live Mode'); ?></label>
								</div>
							</div>
								<span class="label-content"><?php echo Inflector::humanize($paymentGatewaySetting['PaymentGatewaySetting']['key']); ?></span>
								<div class="test-mode-left grid_left">
									<?php echo $this->Form->input("PaymentGatewaySetting.{$paymentGatewaySetting['PaymentGatewaySetting']['id']}.test_mode_value", $options); ?>
								</div>
								<div class="test-mode-right grid_left">
									<?php
										$options['value'] = $paymentGatewaySetting['PaymentGatewaySetting']['live_mode_value'];
										echo $this->Form->input("PaymentGatewaySetting.{$paymentGatewaySetting['PaymentGatewaySetting']['id']}.live_mode_value", $options);
									?>
								</div>
							</div>
						</fieldset>
					<?php endif; ?>
					<?php if($paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'masspay_API_UserName' || $paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'masspay_API_Password' || $paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'masspay_API_Signature'): ?>
						<?php if($j == 0):?>
							<fieldset class="fields-block round-5">
								<h3><?php echo __l('Mass Payment Details'); ?></h3>  
								<div class="content-info">
									<p><?php echo __l('Masspay used to send money to user.');?></p>
									<p><?php echo __l('Create masspay API from paypal profile. Refer').' ';?><a href='https://www.paypal.com/in/cgi-bin/webscr'>https://www.paypal.com/in/cgi-bin/webscr</a></p>
								</div>
						<?php endif;?>
								<div class="clearfix test-mode-content">
									<span class="label-content"><?php echo Inflector::humanize($paymentGatewaySetting['PaymentGatewaySetting']['key']); ?></span>
									<div class="test-mode-left  grid_left">
										<?php echo $this->Form->input("PaymentGatewaySetting.{$paymentGatewaySetting['PaymentGatewaySetting']['id']}.test_mode_value", $options); ?>
									</div>
									<div class="test-mode-right grid_left">
										<?php
											$options['value'] = $paymentGatewaySetting['PaymentGatewaySetting']['live_mode_value'];
											echo $this->Form->input("PaymentGatewaySetting.{$paymentGatewaySetting['PaymentGatewaySetting']['id']}.live_mode_value", $options);
										?>
									</div>
								</div>
						<?php if($j == 2):?>
							</fieldset>
						<?php endif;?>
						<?php $j++;?>
					<?php endif;?>
					<?php if($paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'adaptive_API_AppID' || $paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'adaptive_API_Signature' || $paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'adaptive_API_Password' || $paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'adaptive_API_UserName'):?>
						<?php if($n == 0):?>
							<fieldset class="fields-block round-5">
								<h3><?php echo __l('Adaptive Payment Details'); ?></h3>  	
								<div class="content-info">
									<p><?php echo __l('Adaptive used to send money to seller.');?></p>
									<p><?php echo __l('Create Adaptive API from PayPal profile. Refer').' ';?><a href='https://www.paypal.com/in/cgi-bin/webscr'>https://www.paypal.com/in/cgi-bin/webscr</a></p>
								</div>
						<?php endif;?>
								<div class="clearfix test-mode-content">
									<span class="label-content"><?php echo Inflector::humanize($paymentGatewaySetting['PaymentGatewaySetting']['key']); ?></span>
									<div class="test-mode-left grid_left">
										<?php echo $this->Form->input("PaymentGatewaySetting.{$paymentGatewaySetting['PaymentGatewaySetting']['id']}.test_mode_value", $options); ?>
									</div>
									<div class="test-mode-right grid_left">
										<?php
											$options['value'] = $paymentGatewaySetting['PaymentGatewaySetting']['test_mode_value'];
											$options['div'] = array('id' => "setting-{$paymentGatewaySetting['PaymentGatewaySetting']['key']}");
											$options['value'] = $paymentGatewaySetting['PaymentGatewaySetting']['live_mode_value'];
											echo $this->Form->input("PaymentGatewaySetting.{$paymentGatewaySetting['PaymentGatewaySetting']['id']}.live_mode_value", $options);
										?>
									</div>
								</div>
						<?php if($n == 3):?>
							</fieldset>
						<?php endif;?>
						<?php $n++;?>
					<?php endif;?>
					<?php if($paymentGatewaySetting['PaymentGatewaySetting']['key'] == 'MRB_ID' ):?>
						<fieldset class="fields-block round-5">
							<h3><?php echo __l('Merchant Referral Bonus ID'); ?></h3>  	
							<div class="content-info">
								<p><?php echo __l('Copy your ID, which is at the end of the Referral Email URL: ');?></p>
								<p><a href='https://www.paypal.com/in/cgi-bin/webscr'>https://www.paypal.com/cgi-bin/webscr?cmd=_web-referrals-mrb</a></p>
							</div>
							<div class="clearfix test-mode-content">
								<span class="label-content"><?php echo Inflector::humanize($paymentGatewaySetting['PaymentGatewaySetting']['key']); ?></span>
								<div class="test-mode-left grid_left">
									<?php echo $this->Form->input("PaymentGatewaySetting.{$paymentGatewaySetting['PaymentGatewaySetting']['id']}.test_mode_value", $options); ?>
								</div>
								<div class="test-mode-right grid_left">
									<?php
										$options['value'] = $paymentGatewaySetting['PaymentGatewaySetting']['live_mode_value'];
										echo $this->Form->input("PaymentGatewaySetting.{$paymentGatewaySetting['PaymentGatewaySetting']['id']}.live_mode_value", $options);
									?>
								</div>
							</div>
						</fieldset>			
				<?php endif; ?>
	<?php
            }
		}
	?>
	<?php 
		//nganLuong Begin
		if ($paymentGatewaySettings && $this->request->data['PaymentGateway']['id'] == ConstPaymentGateways::NganLuong) {
		?>
			<fieldset class="fields-block round-5">
				<h3><?php echo __l('Details payee'); ?></h3>  	
				<div class="content-info">
					<p><?php echo __l('Ngân Lượng Payment Info');?></p>
				</div>
				<div class="clearfix test-mode-content">
				<?php
					foreach($paymentGatewaySettings as $paymentGatewaySetting) {
						if($paymentGatewaySetting['PaymentGatewaySetting']['key'] != 'is_enable_for_project'){
							$options['div'] = array('id' => "setting-{$paymentGatewaySetting['PaymentGatewaySetting']['key']}");
							if (!empty($paymentGatewaySetting['PaymentGatewaySetting']['description']) && empty($options['after'])):
								$options['help'] = "{$paymentGatewaySetting['PaymentGatewaySetting']['description']}";
							else:
								$options['help'] = '';
							endif;
							$options['value'] = $paymentGatewaySetting['PaymentGatewaySetting']['live_mode_value'];
							echo $this->Form->input("PaymentGatewaySetting.{$paymentGatewaySetting['PaymentGatewaySetting']['id']}.live_mode_value", $options);
						}
					}
				?>
				</div>
			</fieldset>
	<?php
		}
		//nganLuong End
	?>
	
	</fieldset>
	<div class="submit-block clearfix">
	<?php echo $this->Form->end(__l('Update'));?>
	</div>
</div>